package com.tedu.checkIn.controller;

import com.tedu.checkIn.pojo.dto.ExcusedParam;
import com.tedu.checkIn.pojo.dto.ExcusedQuery;
import com.tedu.checkIn.pojo.vo.ExcusedVO;
import com.tedu.checkIn.service.ExcusedService;
import com.tedu.common.response.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Slf4j@RequestMapping("/v1/checkIn/excused")
public class ExcusedController {
    @Autowired
    ExcusedService excusedService;

    @GetMapping("/select")
    public JsonResult select(ExcusedQuery excusedQuery) {
        log.debug("查询请假信息列表，参数={}",excusedQuery);
        List<ExcusedVO> list=excusedService.select(excusedQuery);
        log.debug("查询请假信息列表，入数={}，出参={}",excusedQuery,list);
        return JsonResult.ok(list);
    }

    @PostMapping("/save")
    public JsonResult save(ExcusedParam excusedParam) {
        log.debug("保存请假信息，参数={}",excusedParam);
        excusedService.save(excusedParam);
        return JsonResult.ok();
    }

    @PostMapping("/delete/{id}")
    public JsonResult delete(@PathVariable Integer id) {
        log.debug("删除请假信息，参数={}",id);
        excusedService.delete(id);
        return JsonResult.ok();
    }
}
